package com.thor.palmmall.util.pay;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @ClassName: ContextHolderUtils
 * @Description: TODO(上下文工具类)
 * @author 张代浩
 * @date 2012-12-15 下午11:27:39
 *
 */
public class ContextHolderUtils {
  /**
   * SpringMvc下获取request
   * 
   * @return
   */
  public static HttpServletRequest getRequest() {
    ServletRequestAttributes attrs = ((ServletRequestAttributes) RequestContextHolder
        .getRequestAttributes());
    return attrs == null ? null : attrs.getRequest();
  }

  /**
   * SpringMvc下获取session
   * 
   * @return
   */
  public static HttpSession getSession() {
    return getRequest() == null ? null : getRequest().getSession();
  }

}
